---
title: Initialize Engine
description: Learn how to use the initialize method in @embedpdf/engines to set up the PDFium library.
searchable: true
---

# initialize

Initializes the PDF engine and the underlying WebAssembly library.

## Signature

```typescript
initialize(): PdfTask<boolean>;
````

## Description

This method **must be called once** before any other engine methods can be used. It sets up the PDFium environment within the WebAssembly module, preparing it for document processing.

Attempting to call other methods like `openDocumentUrl` before `initialize` has completed will result in an error.

## Parameters

This method takes no parameters.

## Returns

`PdfTask<boolean>`

A **`Task`** that resolves with `true` once the engine has been successfully initialized and is ready for use.

See [Concepts: Tasks](../tasks.md) for more on how to handle asynchronous operations.

## Example

```typescript
// Assuming 'engine' is a newly created WebWorkerEngine or PdfiumEngine instance

async function setupPdfProcessor() {
  try {
    const success = await engine.initialize().toPromise();
    if (success) {
      console.log('PDF engine is ready!');
      // You can now safely call other engine methods.
    }
  } catch (error) {
    console.error('Failed to initialize PDF engine:', error);
  }
}

setupPdfProcessor();
```

## See Also

  - [destroy](destroy.md)